/*
 * BaseHelper.java
 *
 * Created on 18 de julio de 2005, 12:30 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.src.computec.radar.consultas.base.helper;

import com.src.computec.radar.consultas.base.constantes.ConstantesGenerales;
import com.src.computec.radar.consultas.base.dao.BaseFactoryDAO;
import com.src.log4j.logger.custom.XLogger;


public abstract class BaseHelper {

    private static XLogger xLogger;
    private BaseFactoryDAO factoryDAO;

    /** Creates a new instance of BaseService */
    protected BaseHelper() {
        this.xLogger = (XLogger) XLogger.getLogger(this.getClass().getName());
        this.initializeFactoryDAO();
    }

    private void initializeFactoryDAO() {
        String factoryDAOClassName = ConstantesGenerales.getInstance().FACTORYDAO_CLASSNAME;
        try {
            this.setFactoryDAO((BaseFactoryDAO) Class.forName(factoryDAOClassName).newInstance());
        }
        catch (InstantiationException e) {
            xLogger.lethal("BaseHelper:initializeFactoryDAO:", e);
        }
        catch (ClassNotFoundException e) {
            xLogger.lethal("BaseHelper:initializeFactoryDAO:", e);
        }
        catch (IllegalAccessException e) {
            xLogger.lethal("BaseHelper:initializeFactoryDAO:", e);
        }
    }

    public BaseFactoryDAO getFactoryDAO() {
        return factoryDAO;
    }

    public void setFactoryDAO(BaseFactoryDAO factoryDAO) {
        this.factoryDAO = factoryDAO;
    }
}